 /** Scrambles a given word.
 * @param word the word to be scrambled
 * @return the scrambled word (possibly equal to word)
 * Precondition: word is either an empty string or contains only uppercase letters.
 * Postcondition: the string returned was created from word as follows:
 * - the word was scrambled, beginning at the first letter and continuing from left to right
 * - two consecutive letters consisting of "A" followed by a letter that was not "A" were swapped
 * - letters were swapped at most once
 */
public static String scrambleWord(String word)
    if (word.length() < 2) return word;
    for (int i=0; i<word.length(); i++ ) {
        if (word.charAt(i) == 'A' && i < word.length()-1){
            if (word.charAt(i+1) != 'A') {
                String start = "";
                String end = "";
                if (i>0) {
                    start = word.substr(0,i);
                }
                if (i+1<word.length()) {
                    end = word.substr(i+1);
                }
                word = start + word.charAt(i+1) + word.charAt(i) +end;
        }
    }
    return word;
}